﻿function createAnimation()
{
    var refCtrl = document.getElementById("refreshImageHost");
    var ctrl = document.getElementById("silverlightControlHost");
    if(ctrl!=null)
    {    
        ctrl.style.display = 'none';
        refCtrl.style.display = 'block';
    }
}

function createSilverlight()
{
    var refCtrl = document.getElementById("refreshImageHost");
    var ctrl = document.getElementById("silverlightControlHost");
    if(ctrl!=null)
    {    
        ctrl.style.display = 'block';
        refCtrl.style.display = 'none';
    }

    var controlID = "SilverlightControl";
	Silverlight.createObjectEx({
		source: "Page.xaml",
		parentElement: document.getElementById("silverlightControlHost"),
		id: controlID,
		properties: {
			width: "100%",
			height: "100%",
			version: "1.1"
		},
		events: {		    
			onError: function(sender, args) {
				var errorDiv = document.getElementById("errorLocation");
				if (errorDiv != null) {
					var errorText = args.errorType + "- " + args.errorMessage;
							
					if (args.ErrorType == "ParserError") {
						errorText += "<br>File: " + args.xamlFile;
						errorText += ", line " + args.lineNumber;
						errorText += " character " + args.charPosition;
					}
					else if (args.ErrorType == "RuntimeError") {
						errorText += "<br>line " + args.lineNumber;
						errorText += " character " +  args.charPosition;
					}
					errorDiv.innerHTML = errorText;
				}	
			}
		}
	});
	
	// Give the keyboard focus to the Silverlight control by default
	window.onload = function() {
	    
		var silverlightControl = document.getElementById(controlID);
		if (silverlightControl)
			silverlightControl.focus();			
	}
	
	
		
	
}
